﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HandyControl.Controls;
using PlaceOrder_Client.Events;
using DevExpress.Mvvm;
using DevExpress.Mvvm.Native;
using PlaceOrder_Client.ViewModels;
namespace PlaceOrder_Client.Views
{
    /// <summary>
    /// RequestChatMessageReviewView.xaml 的交互逻辑
    /// </summary>
    public partial class RequestChatMessageReviewView : System.Windows.Window
    {
        public RequestChatMessageReviewView()
        {
            InitializeComponent();

            //DevExpress.Mvvm.Messenger.Default.Register<string>(this, PlaceOrder_Client.Models.Common.MessageToken.RefreshCang, HandleRefreshAll);
            //DevExpress.Mvvm.Messenger.Default.Register<string>(this, "TradeMessageToken", HandleRefreshAll);

            // 注册接收消息
            Messenger.Default.Register<string>(this, "DefaultTradeMessageToken", ReceiveTitleMessage);
        }
        private void ReceiveTitleMessage(string tradeNum)
        {
            checkComboBox.SelectedItems.Add(tradeNum);
        }
        public  void AddDefaultTradeNum(string tradeNum)
        {
            checkComboBox.SelectedItems.Add(tradeNum);
        }
        private  void HandleRefreshAll(int tradeId)
        {

        }


        
        private void CheckComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RequestChatMessageReviewViewModel.SelectedTradeNums = this.checkComboBox.SelectedItems.Cast<string>().ToList();
            //var s = this.checkComboBox.SelectedItems;
            //{
            //    if (e.AddedItems.Count > 0)
            //    {
            //        List<string> addedItemsList = e.AddedItems.Cast<string>().ToList();
            //        ChatCheckBoxEventService.OnCheckComboBoxSelectionChanged2(addedItemsList, null);
            //    }


            //    if (e.RemovedItems.Count > 0)
            //    {
            //        List<string> removedItemsList = e.RemovedItems.Cast<string>().ToList();
            //        ChatCheckBoxEventService.OnCheckComboBoxSelectionChanged2(null, removedItemsList);
            //    }
        }
    }
}
